#pragma once

class GeoClipmapTerrain
{
public:
	GeoClipmapTerrain(void);
	~GeoClipmapTerrain(void);

	int Init(int clipmapN, float heightScale, const char *hmFilePath, int x, int z);
	void Fini();

	void OnViewerMove(int xOffset, int zOffset);

private:
	void UpdateBufferBand(char* buffer, int bufferInitX, int bufferInitZ, int bufferXStride, int bufferZStride,
		int fileInitX, int fileInitY, int fileXStride, int fileYStride, 
		int count);

private:
	int clipmap_n_;
	int buffer_n_;
	int viewer_x_, viewer_z_;
	int buffer_x_, buffer_z_;
	FIBITMAP *dib_;
	int map_w_, map_h_;
	const int buffer_ext_;
	float heightScale_;
	typedef struct _ClipLevelInfo
	{
		char *buffer;
		int interval;
		int buffer_x_;
		int buffer_z_;
		GLuint texId;
	}ClipLevelInfo;
	std::vector<ClipLevelInfo> clipLevels_;

// disable
private:
	GeoClipmapTerrain(const GeoClipmapTerrain &);
	GeoClipmapTerrain& operator=(const GeoClipmapTerrain &);
};
